<?php
namespace app\admin\model;

use think\Model;

/**
 * @手册分类
 */
class ManualGroupModel extends Model
{
    // 设置数据表（不含前缀）
    protected $name = 'manual_group';
    public function __construct($data = [])
    {
        parent::__construct($data);
    }
    
    //保存数据
    public function saveData($data,$where=[]){
        $return = $this::allowField(true)->save($data,$where);
        return $return;
    }
    
    //获取总数量
    public function getCount($where=[['status','neq',-1]]){
        $return = $this::allowField(true)->where($where)->count();
        return $return;
    }
    
    /**
     * @查询列表分页数据
     */
    public function selectDataByPage($page=1,$limit=10,$where=[['status','neq',-1]]){
        $return = $this::field('id,title,status,sort,pid')->where($where)->page($page.','.$limit)->order('id desc')->select();
        return $return;
    }
    
    //删除数据
    public function del($where){
        $return = $this::save(['status'=>-1,'id'=>$where['id']],$where);
        return $return;
    }
    
    /**
     * @获取数据
     */
    public function selectListData($where=[['status','neq',-1]]){
        $return = $this::field('id,title,status,sort,pid')->where($where)->order('sort desc,id desc')->select();
        return $return;
    }
}
